ActiveDirectoryMembershipProvider 和參照完整性 (ActiveDirectoryMembershipProvider and referential integrity)


問題描述

ActiveDirectoryMembershipProvider 和參照完整性 (ActiveDirectoryMembershipProvider and referential integrity)

In the past, when I implemented my own authentication mechanisms I would have a user table with relationships to other tables in my application's MySQL database.  However, now that I'm considering using ActiveDirectoryMembershipProvider, I see no way to create similar relationships between AD users and those tables.

What's the normal way to resolve this issue?  Should I just accept the fact that someone could potentially insert records with user IDs that don't correspond to existing users?  I don't realistically expect this to happen, but I'm used to ensuring integrity at the database level.

‑‑‑‑‑

參考解法

方法 1:

I don't know of anyway you could do this via MySQL.  If you were using SQL server, you could write a trigger that would call a C# dll that would verify that they were an AD member.  Then if they weren't you could block the insertion into the DB.  You might be able to do something like this with MySQL, but my knowledge of MySQL is pretty slim.

方法 2:

I think you'll have to give up on database referential integrity in this case. Just have your application code check for the existence of the Active Directory account before adding the record to the DB.

In theory, some user could go in manually and type a SQL INSERT statement which refers to an invalid AD account. But in practice, hopefully you aren't giving a bunch of users direct table access. If the application code is the only thing accessing the DB, the application code is validating the account before inserting the row, and that validation code is tested, then you should be OK.

Just to be safe, you could have a nightly batch process that validates all rows in your referencing table(s) against Active Directory. If it finds any inconsistency, it can send you an email. This won't prevent integrity violations, but at least it will let you know about them.

(by Andy WestandrewWinnRichard Beier)

參考文件

  1. ActiveDirectoryMembershipProvider and referential integrity (CC BY‑SA 3.0/4.0)

#asp.net-membership #ASP.NET #referential-integrity #active-directory #MySQL






相關問題

更改會員等級時區 (change membership class time zone)

將 AspNetSqlMembershipProvider 用戶遷移到 WebMatrix (Migrate AspNetSqlMembershipProvider users to WebMatrix)

Beberapa aplikasi dengan keanggotaan dan nama aplikasi yang sama (Multiple applications with membership and same applicationName)

簡單的會員管理帳戶 (Simple Membership Admin Accout)

如何設置 RIA 服務以使用現有的 ASP.Net 成員基礎 (How to setup RIA Services to use an existing ASP.Net membership base)

具有多個數據庫或提供程序的 MVC4 簡單成員身份驗證 (MVC4 Simple Membership authentication with multiple databases or providers)

班級設計決策 (Class design decision)

從 Web.Config 獲取 MembershipProvider 的屬性 (Get MembershipProvider's Properties from Web.Config)

會員 API WP7 (Membership API WP7)

模擬會員 (Mocking Membership)

如何使用 LINQ 和 ASP.NET MVC 持久化用戶與其關聯的數據庫? (How do I persist which database a user is associated with it using LINQ and ASP.NET MVC?)

關於在 Web 應用程序中使用 ASP.NET 安全性和成員資格 (About using ASP.NET security and Membership in web applications)







留言討論